import { createApp } from 'vue';
import ElementPlus from 'element-plus'
import Index from '../components/Index.vue';

if (window.frameElement?.id == 'learnHelperIframe') {
  const container = $('.helper-popup-container');
  const tabs = container.find('.helper-tabs')
  //创建额外按钮
  const newElement = $('<a href="javascript:void(0);" onclick="changePage(\'hero\')" class="btn tabs-btn" data-role="activeTarget"><span>💕成教助手</span></a>');
  tabs.append(newElement)
  //todo)):绑定点击事件,更改激活状态
  
  //创建额外的页面
  const index = document.createElement('div')
  //创建Vue实例
  const app = createApp(Index)
  app.use(ElementPlus)
  app.mount(index)
  //添加页面到dom中
  const chatPage = $('.helper-popup-container > #chat-page')
  $(index).insertAfter(chatPage)

  //点击继续学习按钮
  const learnBtnEle = document.querySelector('#mCSB_1_container div.detail-body > div.helper-detail-row.doing > div.btn-wrap > a')
  if (learnBtnEle.textContent == '继续学习') {
    console.log(learnBtnEle.onclick())
  }

}